﻿<script src="~/Scripts/Highcharts-3.0.1/js/highcharts.js"></script>
@using FTBS.Models.Entities.Concert
@model List<FTBS.Models.Entities.Concert.ReportTube>
@{
    ViewBag.Title = "Thống kê";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    ViewBag.count = 0;
    //===========================================
    List<ReportTube> theatersData = ViewBag.TheaterData;
    List<ReportTube> cateData = ViewBag.CateRank;
    List<ReportTube> SystemBalance = ViewBag.SystemBalance;
    List<ReportTube> TheaterBalance = ViewBag.TheaterBalance;
    string usn = ViewBag.Supplier;
    DateTime fDate = ViewBag.FDate;
    DateTime tDate = ViewBag.TDate;
    //===========================================
    double totalBought = 0;
    double totalSold = 0;
    int totalBoughtNum = 0;
    int totalSoldNum = 0;
    //system
    double realBalance = 0;
    double realTotalRevenue = 0;
    double realTotalBalance = 0;
    //Supplier
    double totalPriceBalance = 0;
    //theater
    int totalNumberBalance = 0;

    //======================Sub data================================
    List<ReportTube> AdminSoldRank = new List<ReportTube>();
    Dictionary<string, double> AdminSoldPriceRank = new Dictionary<string, double>();
    Dictionary<string, int> AdminSoldNumberRank = new Dictionary<string, int>();
    List<ReportTube> TheaterSoldRank = new List<ReportTube>();
    Dictionary<string, double> TheaterSoldPriceRank = new Dictionary<string, double>();
    Dictionary<string, int> TheaterSoldNumberRank = new Dictionary<string, int>();

    Dictionary<string, int> TotalReturnTicket = new Dictionary<string, int>();
    Dictionary<string, int> TheatersReturnTicket = new Dictionary<string, int>();
    Dictionary<string, int> CategoriesRanking = new Dictionary<string, int>();
    List<ReportTube> DayRank = ViewBag.DayRank;
    List<ReportTube> MonthRank = ViewBag.MonthRank;

    Dictionary<string, string> ListSoldSuppliersName = new Dictionary<string, string>();
    Dictionary<int, string> ListSoldTheaters = new Dictionary<int, string>();
    //===========================================================================

    string sup = null;
    string theater = null;
    int tYear = 0;
    int year = 0;
    bool add = false;
    bool tAdd = false;
    ReportTube reportTube = new ReportTube();
    ReportTube tReportTube = new ReportTube();
    //==============for detail page=============
    string fTime = fDate.ToString("dd/MM/yyyy");
    string tTime = tDate.ToString("dd/MM/yyyy");
    
}
<style>
    .center {
        text-align: center;
    }

    .right {
        text-align: right;
    }
</style>
<div id="report" style="width: 100%">
    @*@((DotNet.Highcharts.Highcharts)ViewBag.AllChart)*@
    @if (Model.Count > 0)
    {
        <legend id="ReportTitle">THỐNG KÊ THEO NĂM TỪ  @fDate.ToString("dd/MM/yyyy") ĐẾN @tDate.ToString("dd/MM/yyyy")
        </legend>
        if ((int)ViewBag.mode == 0)
        {
            //=====================Suppliers statistic=====================================
            foreach (var bItem in Model)
            {
                double priceBalance = 0;
                int numberBalance = 0;
                if (!(sup == bItem.SupplierId && year == bItem.ReportDate.Year))
                {
                    if (add == true)
                    {
                        // before create new tube, push the old tube to reportData
                        AdminSoldRank.Add(reportTube);
                        reportTube = new ReportTube();
                    }
                    sup = bItem.SupplierId;
                    year = bItem.ReportDate.Year;
                    // create new tube
                    reportTube.ReportDate = bItem.ReportDate;
                    reportTube.SupplierId = bItem.SupplierId;
                    reportTube.SupplierName = bItem.SupplierName;
                    reportTube.NumberOfTicket = bItem.NumberOfTicket;
                    reportTube.TotalPurePrice = bItem.TotalPurePrice;
                    reportTube.NumberOfSoldTicket = bItem.NumberOfSoldTicket;
                    reportTube.TotalPrice = bItem.TotalPrice;
                    if (add == false) { add = true; }
                }
                // else, update new one
                else
                {
                    //update number of tiket and totalprice
                    reportTube.NumberOfTicket = reportTube.NumberOfTicket + bItem.NumberOfTicket;
                    reportTube.TotalPurePrice = reportTube.TotalPurePrice + bItem.TotalPurePrice;
                    reportTube.NumberOfSoldTicket = reportTube.NumberOfSoldTicket + bItem.NumberOfSoldTicket;
                    reportTube.TotalPrice = reportTube.TotalPrice + bItem.TotalPrice;
                    if (add == false) { add = true; }
                }
                //===============================================================================
                //caluculating balance in each tube
                priceBalance = bItem.TotalPrice - bItem.TotalPurePrice;
                numberBalance = bItem.NumberOfReturnTicket;//bItem.NumberOfSoldTicket -bItem.NumberOfTicket;
                //calculating final total numbers
                totalBought = totalBought + bItem.TotalPurePrice;
                totalBoughtNum = totalBoughtNum + bItem.NumberOfTicket;
                totalSold = totalSold + bItem.TotalPrice;
                totalSoldNum = totalSoldNum + bItem.NumberOfSoldTicket;
                totalNumberBalance = totalNumberBalance + numberBalance;
                totalPriceBalance = totalPriceBalance + priceBalance;
                //=============================================================================
                if (!TotalReturnTicket.Keys.Contains(bItem.SupplierId))
                {
                    TotalReturnTicket.Add(bItem.SupplierId, -numberBalance);
                }
                else
                {
                    TotalReturnTicket[bItem.SupplierId] = TotalReturnTicket[bItem.SupplierId] + (-numberBalance);
                }
                //=============================================================================
                if (!ListSoldSuppliersName.Keys.Contains(bItem.SupplierId))
                {
                    ListSoldSuppliersName.Add(bItem.SupplierId, bItem.SupplierName);
                }
            }
            AdminSoldRank.Add(reportTube);
            //======================================================================================

            //======================================Theater statistic===============================
            foreach (var bItem in theatersData)
            {
                double priceBalance = 0;
                int numberBalance = 0;
                if (!(theater == bItem.TheaterName && tYear == bItem.ReportDate.Year))
                {
                    if (tAdd == true)
                    {
                        // before create new tube, push the old tube to reportData
                        TheaterSoldRank.Add(tReportTube);
                        tReportTube = new ReportTube();
                    }
                    theater = bItem.TheaterName;
                    tYear = bItem.ReportDate.Year;
                    // create new tube
                    tReportTube.ReportDate = bItem.ReportDate;
                    tReportTube.SupplierId = bItem.SupplierId;
                    tReportTube.SupplierName = bItem.SupplierName;
                    tReportTube.TheaterName = bItem.TheaterName;
                    tReportTube.NumberOfTicket = bItem.NumberOfTicket;
                    tReportTube.TotalPurePrice = bItem.TotalPurePrice;
                    tReportTube.NumberOfSoldTicket = bItem.NumberOfSoldTicket;
                    tReportTube.TotalPrice = bItem.TotalPrice;
                    if (tAdd == false) { tAdd = true; }
                }
                // else, update new one
                else
                {
                    //update number of tiket and totalprice
                    tReportTube.NumberOfTicket = tReportTube.NumberOfTicket + bItem.NumberOfTicket;
                    tReportTube.TotalPurePrice = tReportTube.TotalPurePrice + bItem.TotalPurePrice;
                    tReportTube.NumberOfSoldTicket = tReportTube.NumberOfSoldTicket + bItem.NumberOfSoldTicket;
                    tReportTube.TotalPrice = tReportTube.TotalPrice + bItem.TotalPrice;
                    if (tAdd == false) { tAdd = true; }
                }
                //=================================================================
                //caluculating balance in each tube
                priceBalance = bItem.TotalPrice - bItem.TotalPurePrice;
                numberBalance = bItem.NumberOfReturnTicket;//bItem.NumberOfSoldTicket -bItem.NumberOfTicket;
                //===============================================================
                if (!TheatersReturnTicket.Keys.Contains(bItem.TheaterName))
                {
                    TheatersReturnTicket.Add(bItem.TheaterName, -numberBalance);
                }
                else
                {
                    TheatersReturnTicket[bItem.TheaterName] = TheatersReturnTicket[bItem.TheaterName] + (-numberBalance);
                }
                //===============================================================
                if (!ListSoldTheaters.Keys.Contains(bItem.TheaterId))
                {
                    ListSoldTheaters.Add(bItem.TheaterId, bItem.TheaterName);
                }
            }
            TheaterSoldRank.Add(tReportTube);
            //============================================================================================
            foreach (var item in SystemBalance)
            {
                realTotalRevenue = realTotalRevenue + item.TotalPrice;
                realBalance = item.TotalPrice - item.TotalPurePrice;
                realTotalBalance = realTotalBalance + realBalance;
            }

            //========= Present Mode 0 ==============
        <div class="tab-control" data-role="tab-control">
            <ul class="tabs">
                <li class="active"><a href="#system" id="titletab1">TỔNG QUAN HỆ THỐNG</a></li>
                <li><a href="#suppliers" id="titletab2">THỐNG KÊ CÁC ĐỐI TÁC</a></li>
                <li><a href="#theaters" id="titletab3">THỐNG KÊ CÁC RẠP</a></li>
            </ul>

            <div class="frames">
                <div class="frame" id="system" style="width: 100%">
                    <div>
                        @*OverView Statistic*@
                        <table class="table bordered hovered" style="width: 100%">
                            <tr style="background-color: teal; color: white">
                                <th>Vé đã bán</th>
                                <th>Vé hoàn trả lại</th>
                                <th>Tổng doanh thu</th>
                                <th>Tổng lợi nhuận</th>
                            </tr>
                            <tr>
                                <td class="right">@totalSoldNum</td>
                                <td class="right">@(-totalNumberBalance)</td>
                                <td class="right">@realTotalRevenue.ToString("0,000")</td>
                                <td class="right">@realTotalBalance.ToString("0,000")</td>
                            </tr>
                        </table>
                        <hr />
                        @*Overview ranking of date range*@
                        <div style="display: block; width: 100%">
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Thể loại phim bán chạy nhất
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Thể loại
                                        </th>
                                        <th>Vé bán ra
                                        </th>
                                    </tr>
                                    @{int cRank = 0;

                                      foreach (var n in cateData)
                                      {
                                          if (!CategoriesRanking.Keys.Contains(n.CategoryName))
                                          {
                                              CategoriesRanking.Add(n.CategoryName, n.NumberOfSoldTicket);
                                          }
                                          else
                                          {
                                              CategoriesRanking[n.CategoryName] = CategoriesRanking[n.CategoryName] + n.NumberOfSoldTicket;
                                          }
                                      }
                                      CategoriesRanking = CategoriesRanking.OrderByDescending(cr => cr.Value).ToDictionary(cr => cr.Key, cr => cr.Value);
                                    }
                                    @foreach (var cR in CategoriesRanking)
                                    {
                                        <tr>
                                            <td class="center">
                                                @(cRank = cRank + 1)
                                            </td>
                                            <td>
                                                @cR.Key
                                            </td>
                                            <td class="right">
                                                @cR.Value
                                            </td>
                                        </tr> 
                                    }
                                </table>
                            </div>
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Ngày trong tuần bán chạy nhất
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Ngày
                                        </th>
                                        <th>Vé bán ra
                                        </th>
                                    </tr>
                                    @{int dRank = 0;
                                      List<ReportTube> sortedDayRank = (
                                          from m in DayRank orderby m.NumberOfSoldTicket descending select m).ToList();
                                    }
                                    @foreach (var n in sortedDayRank)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(dRank = dRank + 1)
                                            </td>
                                            <td class="center">
                                                @if (n.ReportDay == 0)
                                                {@("Chủ nhật")}
                                                else
                                                {@("Thứ ")@(n.ReportDay + 1)}
                                            </td>
                                            <td class="right">
                                                @n.NumberOfSoldTicket
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%;">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Tháng trong năm bán chạy nhất
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Tháng
                                        </th>
                                        <th>Vé bán ra
                                        </th>
                                    </tr>
                                    @{int mRank = 0;
                                      List<ReportTube> sortedMonthRank = (
                                          from m in MonthRank orderby m.NumberOfSoldTicket descending select m).ToList();
                                    }
                                    @foreach (var n in sortedMonthRank)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(mRank = mRank + 1)
                                            </td>
                                            <td class="center">
                                                @n.ReportDate.Month
                                            </td>
                                            <td class="right">
                                                @n.NumberOfSoldTicket
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                        </div>
                    </div>
                        <div style="padding-left: 20px">
                            <input id="btnPrintTab1" class="info detail" type="submit" value="In báo cáo" />
                        </div>
                </div>
                <div class="frame" id="suppliers">
                    <div>
                        <div class="unoverflow" style="max-height: 400px; overflow-y: scroll">
                            <table class="table bordered hovered" style="width: 100%">
                                <tr style="background-color: teal; color: white">
                                    <th style="width: 35%">Đối tác</th>
                                    <th style="width: 15%">Vé bán ra</th>
                                    <th style="width: 20%">Doanh thu</th>
                                    <th style="width: 20%">Lợi nhuận</th>
                                    <th class="detail" style="width: 10%"></th>
                                </tr>
                                @foreach (var item in ListSoldSuppliersName)
                                {
                                    int totalSoldTickets = 0;
                                    double totalSupplierBalance = 0;
                                    double totalSupplierSoldPrice = 0;
                                    List<ReportTube> sortedBalance = (
                                      from sb in SystemBalance
                                      // select tube has 
                                      where sb.SupplierId == item.Key
                                      orderby sb.SupplierId, sb.ReportDate ascending
                                      select sb).ToList();
                                    foreach (var sItem in sortedBalance)
                                    {
                                        double balance = 0;
                                        //caluculating balance in each tube
                                        balance = sItem.TotalPrice - sItem.TotalPurePrice;
                                        totalSupplierBalance = totalSupplierBalance + balance;
                                        totalSoldTickets = totalSoldTickets + sItem.NumberOfSoldTicket;
                                        totalSupplierSoldPrice = totalSupplierSoldPrice + sItem.TotalPrice;
                                    }
                                    <tr>
                                        <td>@item.Value</td>
                                        <td class="right">@totalSoldTickets</td>
                                        <td class="right">@totalSupplierSoldPrice.ToString("0,000")</td>
                                        <td class="right">@totalSupplierBalance.ToString("0,000")</td>
                                        <td class="detail">@Html.ActionLink("Chi tiết", "SystemSuppliersYearsDetail", new { usn = item.Key, fTime, tTime, firstFromTime = fTime, firstToTime = tTime })</td>
                                    </tr>
                                }
                            </table>
                        </div>
                        <hr />
                        @*Ranking in*@
                        <div style="display: block; width: 100%">
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Xếp hạng theo số lượng vé bán ra
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Đối tác
                                        </th>
                                        <th>Số lượng vé
                                        </th>
                                    </tr>
                                    @{int pRank = 0;
                                      foreach (var n in AdminSoldRank)
                                      {
                                          if (!AdminSoldNumberRank.Keys.Contains(n.SupplierName))
                                          {
                                              AdminSoldNumberRank.Add(n.SupplierName, n.NumberOfSoldTicket);
                                          }
                                          else
                                          {
                                              AdminSoldNumberRank[n.SupplierName] = AdminSoldNumberRank[n.SupplierName] + n.NumberOfSoldTicket;
                                          }
                                      }
                                      AdminSoldNumberRank = AdminSoldNumberRank.OrderByDescending(sn => sn.Value).ToDictionary(sn => sn.Key, sn => sn.Value);
                                    }
                                    @foreach (var n in AdminSoldNumberRank)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(pRank = pRank + 1)
                                            </td>
                                            <td>
                                                @n.Key
                                            </td>
                                            <td class="right">
                                                @n.Value
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Xếp hạng theo doanh thu
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Đối tác
                                        </th>
                                        <th>Doanh thu
                                        </th>
                                    </tr>
                                    @{int nRank = 0;
                                      foreach (var n in AdminSoldRank)
                                      {
                                          if (!AdminSoldPriceRank.Keys.Contains(n.SupplierName))
                                          {
                                              AdminSoldPriceRank.Add(n.SupplierName, n.TotalPrice);
                                          }
                                          else
                                          {
                                              AdminSoldPriceRank[n.SupplierName] = AdminSoldPriceRank[n.SupplierName] + n.TotalPrice;
                                          }
                                      }
                                      AdminSoldPriceRank = AdminSoldPriceRank.OrderByDescending(sn => sn.Value).ToDictionary(sn => sn.Key, sn => sn.Value);
                                    }
                                    @foreach (var n in AdminSoldPriceRank)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(nRank = nRank + 1)
                                            </td>
                                            <td>
                                                @n.Key
                                            </td>
                                            <td class="right">
                                                @n.Value.ToString("0,000")
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Xếp hạng theo vé trả lại
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Đối tác
                                        </th>
                                        <th>Vé trả lại
                                        </th>
                                    </tr>
                                    @{int rRank = 0;
                                      TotalReturnTicket = TotalReturnTicket.OrderBy(rt => rt.Value).ToDictionary(rt => rt.Key, rt => rt.Value);
                                    }
                                    @foreach (var n in TotalReturnTicket)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(rRank = rRank + 1)
                                            </td>
                                            <td>
                                                @n.Key
                                            </td>
                                            <td class="right">
                                                @n.Value
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                        </div>
                    </div>
                        <div style="padding-left: 20px">
                            <input id="btnPrintTab2" class="info detail" type="submit" value="In báo cáo" />
                        </div>
                </div>
                <div class="frame" id="theaters">
                    <div>
                        @*Theater Statistic and balancing*@
                        <div class="unoverflow" style="max-height: 400px; overflow-y: scroll">
                            <table class="table bordered hovered" style="width: 100%">
                                <tr style="background-color: teal; color: white">
                                    <th style="width: 35%">Rạp</th>
                                    <th style="width: 15%">Vé bán ra</th>
                                    <th style="width: 20%">Doanh thu</th>
                                    <th style="width: 20%">Lợi nhuận</th>
                                    <th style="width: 10%" class="detail"></th>
                                </tr>
                                @foreach (var item in ListSoldTheaters)
                                {
                                    int totalSoldTickets = 0;
                                    double totalTheaterBalance = 0;
                                    double totalTheaterSoldPrice = 0;
                                    List<ReportTube> sortedTheaterBalance = (
                                      from sb in TheaterBalance
                                      where sb.TheaterId == item.Key
                                      orderby sb.TheaterName, sb.ReportDate ascending
                                      select sb).ToList(); foreach (var sItem in sortedTheaterBalance)
                                    {
                                        double tBalance = 0;
                                        //caluculating balance in each tube
                                        tBalance = sItem.TotalPrice - sItem.TotalPurePrice;
                                        totalTheaterBalance = totalTheaterBalance + tBalance;
                                        totalSoldTickets = totalSoldTickets + sItem.NumberOfSoldTicket;
                                        totalTheaterSoldPrice = totalTheaterSoldPrice + sItem.TotalPrice;
                                    }
                                    <tr>
                                        <td>@item.Value</td>
                                        <td class="right">@totalSoldTickets</td>
                                        <td class="right">@totalTheaterSoldPrice.ToString("0,000")</td>
                                        <td class="right">@totalTheaterBalance.ToString("0,000")</td>
                                        <td class="detail">@Html.ActionLink("Chi tiết", "SystemTheaterYearsDetail", new { usn, theaterId = @item.Key, fTime, tTime, firstFromTime = fTime, firstToTime = tTime })</td>
                                    </tr>
                                }
                            </table>
                        </div>
                        <hr />
                        @*Ranking*@
                        <div style="display: block; width: 100%">
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Xếp hạng rạp theo số lượng vé bán
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Rạp
                                        </th>
                                        <th>Vé bán ra
                                        </th>
                                    </tr>
                                    @{int spRank = 0;
                                      foreach (var m in TheaterSoldRank)
                                      {
                                          if (!TheaterSoldNumberRank.Keys.Contains(m.TheaterName))
                                          {
                                              TheaterSoldNumberRank.Add(m.TheaterName, m.NumberOfSoldTicket);
                                          }
                                          else
                                          {
                                              TheaterSoldNumberRank[m.TheaterName] = TheaterSoldNumberRank[m.TheaterName] + m.NumberOfSoldTicket;
                                          }
                                      }
                                      TheaterSoldNumberRank = TheaterSoldNumberRank.OrderByDescending(sn => sn.Value).ToDictionary(sn => sn.Key, sn => sn.Value);
                                    }
                                    @foreach (var m in TheaterSoldNumberRank)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(spRank = spRank + 1)
                                            </td>
                                            <td>
                                                @m.Key
                                            </td>
                                            <td class="right">
                                                @m.Value
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Xếp hạng rạp theo doanh thu
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Rạp
                                        </th>
                                        <th>Doanh thu
                                        </th>
                                    </tr>
                                    @{int eRank = 0;
                                      foreach (var n in TheaterSoldRank)
                                      {
                                          if (!TheaterSoldPriceRank.Keys.Contains(n.TheaterName))
                                          {
                                              TheaterSoldPriceRank.Add(n.TheaterName, n.TotalPrice);
                                          }
                                          else
                                          {
                                              TheaterSoldPriceRank[n.TheaterName] = TheaterSoldPriceRank[n.TheaterName] + n.TotalPrice;
                                          }
                                      }
                                      TheaterSoldPriceRank = TheaterSoldPriceRank.OrderByDescending(sn => sn.Value).ToDictionary(sn => sn.Key, sn => sn.Value);
                                    }
                                    @foreach (var n in TheaterSoldPriceRank)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(eRank = eRank + 1)
                                            </td>
                                            <td>
                                                @n.Key
                                            </td>
                                            <td class="right">
                                                @n.Value.ToString("0,000")
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Xếp hạng rạp theo vé trả lại
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Rạp
                                        </th>
                                        <th>Vé trả lại
                                        </th>
                                    </tr>
                                    @{int tRank = 0;
                                      TheatersReturnTicket = TheatersReturnTicket.OrderBy(rt => rt.Value).ToDictionary(rt => rt.Key, rt => rt.Value);
                                    }
                                    @foreach (var n in TheatersReturnTicket)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(tRank = tRank + 1)
                                            </td>
                                            <td>
                                                @n.Key
                                            </td>
                                            <td class="right">
                                                @n.Value
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                        </div>
                    </div>
                    <div style="padding-left: 20px">
                        <input id="btnPrintTab3" class="info detail" type="submit" value="In báo cáo" />
                    </div>
                </div>
            </div>
        </div>
        }
        //////////////////////////////////////////////////////////////////////////////////////////////////
        else
        {
            foreach (var bItem in Model)
            {
                double priceBalance = 0;
                int numberBalance = 0;
                if (!(theater == bItem.TheaterName && tYear == bItem.ReportDate.Year))
                {
                    if (tAdd == true)
                    {
                        // before create new tube, push the old tube to reportData
                        TheaterSoldRank.Add(tReportTube);
                        tReportTube = new ReportTube();
                    }
                    theater = bItem.TheaterName;
                    tYear = bItem.ReportDate.Year;
                    // create new tube
                    tReportTube.ReportDate = bItem.ReportDate;
                    tReportTube.SupplierId = bItem.SupplierId;
                    tReportTube.SupplierName = bItem.SupplierName;
                    tReportTube.TheaterName = bItem.TheaterName;
                    tReportTube.NumberOfTicket = bItem.NumberOfTicket;
                    tReportTube.TotalPurePrice = bItem.TotalPurePrice;
                    tReportTube.NumberOfSoldTicket = bItem.NumberOfSoldTicket;
                    tReportTube.TotalPrice = bItem.TotalPrice;
                    if (tAdd == false) { tAdd = true; }
                }
                // else, update new one
                else
                {
                    //update number of tiket and totalprice
                    tReportTube.NumberOfTicket = tReportTube.NumberOfTicket + bItem.NumberOfTicket;
                    tReportTube.TotalPurePrice = tReportTube.TotalPurePrice + bItem.TotalPurePrice;
                    tReportTube.NumberOfSoldTicket = tReportTube.NumberOfSoldTicket + bItem.NumberOfSoldTicket;
                    tReportTube.TotalPrice = tReportTube.TotalPrice + bItem.TotalPrice;
                    if (tAdd == false) { tAdd = true; }
                }
                //=================================================================
                //caluculating balance in each tube
                priceBalance = bItem.TotalPrice - bItem.TotalPurePrice;
                numberBalance = bItem.NumberOfSoldTicket - bItem.NumberOfTicket;
                totalBoughtNum = totalBoughtNum + bItem.NumberOfTicket;
                totalSoldNum = totalSoldNum + bItem.NumberOfSoldTicket;
                totalNumberBalance = totalNumberBalance + numberBalance;
                //===============================================================
                if (!TheatersReturnTicket.Keys.Contains(bItem.TheaterName))
                {
                    TheatersReturnTicket.Add(bItem.TheaterName, -numberBalance);
                }
                else
                {
                    TheatersReturnTicket[bItem.TheaterName] = TheatersReturnTicket[bItem.TheaterName] + (-numberBalance);
                }
                //===============================================================
                if (!ListSoldTheaters.Keys.Contains(bItem.TheaterId))
                {
                    ListSoldTheaters.Add(bItem.TheaterId, bItem.TheaterName);
                }
            }
            TheaterSoldRank.Add(tReportTube);
            //============================================================================================
            foreach (var item in TheaterBalance)
            {
                realTotalRevenue = realTotalRevenue + item.TotalPrice;
                realBalance = item.TotalPrice - item.TotalPurePrice;
                realTotalBalance = realTotalBalance + realBalance;
            }
            //======================Present Mode 1 =================  
            
        <div class="tab-control" data-role="tab-control">
            <ul class="tabs">
                <li class="active" id="titletab4"><a href="#overview">TỔNG QUAN</a></li>
                <li><a href="#suppliertheaters" id="titletab5">THỐNG KÊ CÁC RẠP</a></li>
            </ul>

            <div class="frames">
                <div class="frame" id="overview">
                    <div></div>
                    <table class="table bordered hovered" style="width: 100%">
                        <tr style="background-color: teal; color: white">
                            <th>Tổng vé đã bán</th>
                            <th>Tổng vé hoàn trả lại</th>
                            <th>Tổng doanh thu</th>
                            <th>Tổng lợi nhuận</th>
                        </tr>
                        <tr>
                            <td class="right">@totalSoldNum</td>
                            <td class="right">@(-totalNumberBalance)</td>
                            <td class="right">@realTotalRevenue.ToString("0,000")</td>
                            <td class="right">@realTotalBalance.ToString("0,000")</td>
                        </tr>
                    </table>
                    <div>@*supplier's overview*@

                        <div style="display: block; width: 100%">
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%;">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3" style="font-weight: bold;">Tháng trong năm bán chạy nhất
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Tháng
                                        </th>
                                        <th>Vé bán ra
                                        </th>
                                    </tr>
                                    @{int mRank = 0;
                                      List<ReportTube> sortedMonthRank = (
                                          from m in MonthRank orderby m.NumberOfSoldTicket descending select m).ToList();
                                    }
                                    @foreach (var n in sortedMonthRank)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(mRank = mRank + 1)
                                            </td>
                                            <td class="center">
                                                @n.ReportDate.Month
                                            </td>
                                            <td class="right">
                                                @n.NumberOfSoldTicket
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Ngày trong tuần bán chạy nhất
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Ngày
                                        </th>
                                        <th>Vé bán ra
                                        </th>
                                    </tr>
                                    @{int dRank = 0;
                                      List<ReportTube> sortedDayRank = (
                                          from m in DayRank orderby m.NumberOfSoldTicket descending select m).ToList();
                                    }
                                    @foreach (var n in sortedDayRank)
                                    { 
                                        <tr>
                                            <td class="center">
                                                @(dRank = dRank + 1)
                                            </td>
                                            <td class="center">
                                                @if (n.ReportDay == 0)
                                                { 
                                                    @("Chủ nhật")
                                                }
                                                else
                                                {
                                                    @("Thứ ")@(n.ReportDay + 1)
                                                }
                                            </td>
                                            <td class="right">
                                                @n.NumberOfSoldTicket
                                            </td>
                                        </tr>
                                    }
                                </table>
                            </div>
                            <div style="display: inline-block; width: 32%; vertical-align: top;">
                                <table class="table bordered hovered" style="width: 100%">
                                    <tr style="background-color: teal; color: white">
                                        <th colspan="3">Thể loại phim bán chạy nhất
                                        </th>
                                    </tr>
                                    <tr style="background-color: lightblue;">
                                        <th>STT
                                        </th>
                                        <th>Thể loại
                                        </th>
                                        <th>Vé bán ra
                                        </th>
                                    </tr>
                                    @{int cRank = 0;

                                      foreach (var n in cateData)
                                      {
                                          if (!CategoriesRanking.Keys.Contains(n.CategoryName))
                                          {
                                              CategoriesRanking.Add(n.CategoryName, n.NumberOfSoldTicket);
                                          }
                                          else
                                          {
                                              CategoriesRanking[n.CategoryName] = CategoriesRanking[n.CategoryName] + n.NumberOfSoldTicket;
                                          }
                                      }
                                      CategoriesRanking = CategoriesRanking.OrderByDescending(cr => cr.Value).ToDictionary(cr => cr.Key, cr => cr.Value);
                                    }
                                    @foreach (var cR in CategoriesRanking)
                                    {
                                        <tr>
                                            <td class="center">
                                                @(cRank = cRank + 1)
                                            </td>
                                            <td>
                                                @cR.Key
                                            </td>
                                            <td class="right">
                                                @cR.Value
                                            </td>
                                        </tr> 
                                    }
                                </table>
                            </div>
                        </div>
                    </div>
                        <div style="padding-left: 20px">
                            <input id="btnPrintTab4" class="info detail" type="submit" value="In báo cáo" />
                        </div>
                </div>
                <div class="frame" id="suppliertheaters">
                    <div>
                        @*Theater Statistic and balancing*@
                        <div class="unoverflow" style="max-height: 400px; overflow-y: scroll">
                            <table class="table bordered hovered" style="width: 100%">
                                <tr style="background-color: teal; color: white">
                                    <th style="width: 35%">Rạp</th>
                                    <th style="width: 15%">Vé bán ra</th>
                                    <th style="width: 20%">Doanh thu</th>
                                    <th style="width: 20%">Lợi nhuận</th>
                                    <th style="width: 10%" class="detail"></th>
                                </tr>
                                @foreach (var item in ListSoldTheaters)
                                {
                                    int totalSoldTickets = 0;
                                    double totalTheaterBalance = 0;
                                    double totalTheaterSoldPrice = 0;
                                    List<ReportTube> sortedTheaterBalance = (
                                      from sb in TheaterBalance
                                      where sb.TheaterId == item.Key
                                      orderby sb.TheaterName, sb.ReportDate ascending
                                      select sb).ToList(); foreach (var sItem in sortedTheaterBalance)
                                    {
                                        double tBalance = 0;
                                        //caluculating balance in each tube
                                        tBalance = sItem.TotalPrice - sItem.TotalPurePrice;
                                        totalTheaterBalance = totalTheaterBalance + tBalance;
                                        totalSoldTickets = totalSoldTickets + sItem.NumberOfSoldTicket;
                                        totalTheaterSoldPrice = totalTheaterSoldPrice + sItem.TotalPrice;
                                    }
                                    <tr>
                                        <td>@item.Value</td>
                                        <td class="right">@totalSoldTickets</td>
                                        <td class="right">@totalTheaterSoldPrice.ToString("0,000")</td>
                                        <td class="right">@totalTheaterBalance.ToString("0,000")</td>
                                        <td class="detail">@Html.ActionLink("Chi tiết", "SystemTheaterYearsDetail", new { usn, theaterId = @item.Key, fTime, tTime, firstFromTime = fTime, firstToTime = tTime })</td>
                                    </tr>
                                }
                            </table>
                        </div>
                        <hr />
                        @*Xếp hạng theo thu nhập*@
                        <div style="width: 100%">
                            <div style="display: block; width: 100%">
                                <div style="display: inline-block; width: 32%; vertical-align: top;">
                                    <table class="table bordered hovered" style="width: 100%">
                                        <tr style="background-color: teal; color: white">
                                            <th colspan="3">Xếp hạng rạp theo số lượng vé bán
                                            </th>
                                        </tr>
                                        <tr style="background-color: lightblue;">
                                            <th>STT
                                            </th>
                                            <th>Rạp
                                            </th>
                                            <th>Vé bán ra
                                            </th>
                                        </tr>
                                        @{int spRank = 0;
                                          foreach (var m in TheaterSoldRank)
                                          {
                                              if (!TheaterSoldNumberRank.Keys.Contains(m.TheaterName))
                                              {
                                                  TheaterSoldNumberRank.Add(m.TheaterName, m.NumberOfSoldTicket);
                                              }
                                              else
                                              {
                                                  TheaterSoldNumberRank[m.TheaterName] = TheaterSoldNumberRank[m.TheaterName] + m.NumberOfSoldTicket;
                                              }
                                          }
                                          TheaterSoldNumberRank = TheaterSoldNumberRank.OrderByDescending(sn => sn.Value).ToDictionary(sn => sn.Key, sn => sn.Value);
                                        }
                                        @foreach (var m in TheaterSoldNumberRank)
                                        { 
                                            <tr>
                                                <td class="center">
                                                    @(spRank = spRank + 1)
                                                </td>
                                                <td>
                                                    @m.Key
                                                </td>
                                                <td class="right">
                                                    @m.Value
                                                </td>
                                            </tr>
                                        }
                                    </table>
                                </div>
                                <div style="display: inline-block; width: 32%; vertical-align: top;">
                                    <table class="table bordered hovered" style="width: 100%">
                                        <tr style="background-color: teal; color: white">
                                            <th colspan="3">Xếp hạng rạp theo doanh thu
                                            </th>
                                        </tr>
                                        <tr style="background-color: lightblue;">
                                            <th>STT
                                            </th>
                                            <th>Rạp
                                            </th>
                                            <th>Doanh thu
                                            </th>
                                        </tr>
                                        @{int eRank = 0;
                                          foreach (var n in TheaterSoldRank)
                                          {
                                              if (!TheaterSoldPriceRank.Keys.Contains(n.TheaterName))
                                              {
                                                  TheaterSoldPriceRank.Add(n.TheaterName, n.TotalPrice);
                                              }
                                              else
                                              {
                                                  TheaterSoldPriceRank[n.TheaterName] = TheaterSoldPriceRank[n.TheaterName] + n.TotalPrice;
                                              }
                                          }
                                          TheaterSoldPriceRank = TheaterSoldPriceRank.OrderByDescending(sn => sn.Value).ToDictionary(sn => sn.Key, sn => sn.Value);
                                        }
                                        @foreach (var n in TheaterSoldPriceRank)
                                        { 
                                            <tr>
                                                <td class="center">
                                                    @(eRank = eRank + 1)
                                                </td>
                                                <td>
                                                    @n.Key
                                                </td>
                                                <td class="right">
                                                    @n.Value.ToString("0,000")
                                                </td>
                                            </tr>
                                        }
                                    </table>
                                </div>
                                <div style="display: inline-block; width: 32%; vertical-align: top;">
                                    <table class="table bordered hovered" style="width: 100%">
                                        <tr style="background-color: teal; color: white">
                                            <th colspan="3">Xếp hạng rạp theo vé trả lại
                                            </th>
                                        </tr>
                                        <tr style="background-color: lightblue;">
                                            <th>STT
                                            </th>
                                            <th>Rạp
                                            </th>
                                            <th>Vé trả lại
                                            </th>
                                        </tr>
                                        @{int tRank = 0;
                                          TheatersReturnTicket = TheatersReturnTicket.OrderBy(rt => rt.Value).ToDictionary(rt => rt.Key, rt => rt.Value);
                                        }
                                        @foreach (var n in TheatersReturnTicket)
                                        { 
                                            <tr>
                                                <td class="center">
                                                    @(tRank = tRank + 1)
                                                </td>
                                                <td>
                                                    @n.Key
                                                </td>
                                                <td class="right">
                                                    @n.Value
                                                </td>
                                            </tr>
                                        }
                                    </table>
                                </div>
                            </div>
                        </div>
                            <div style="padding-left: 20px">
                                <input id="btnPrintTab5" class="info detail" type="submit" value="In báo cáo" />
                            </div>
                    </div>
                </div>
            </div>
        </div>   
        }
    }
    else
    {
        <div class="tab-control" data-role="tab-control">
            <ul class="tabs">
                <li class="active"><a href="#sys">TỔNG QUAN HỆ THỐNG</a></li>
                <li><a href="#sup">THỐNG KÊ CÁC ĐỐI TÁC</a></li>
                <li><a href="#thea">THỐNG KÊ CÁC RẠP</a></li>
            </ul>

            <div class="frames">
                <div class="frame" id="sys" style="width: 100%">
                    <div style="text-align: center; font-weight: bold">
                        @{string message = null;
                          if (fDate > tDate)
                          {
                              message = "Ngày trong mục 'Từ ngày' không được lớn hơn ngày trong mục 'Đến ngày'";
                          }
                          else
                          {
                              message = "Không có dữ liệu giao dịch của hệ thống trong thời gian từ " + fDate.ToString("dd/MM/yyyy") + " đến " + tDate.ToString("dd/MM/yyyy");
                          }
                        }
                        @message
                    </div>
                </div>
                <div class="frame" id="sup" style="width: 100%">
                    <div style="text-align: center; font-weight: bold">
                        @{
                          if (fDate > tDate)
                          {
                              message = "Ngày trong mục 'Từ ngày' không được lớn hơn ngày trong mục 'Đến ngày'";
                          }
                          else
                          {
                              message = "Không có dữ liệu giao dịch của các ôối tác trong thời gian từ " + fDate.ToString("dd/MM/yyyy") + " đến " + tDate.ToString("dd/MM/yyyy");
                          }
                        }
                        @message
                    </div>
                </div>
                <div class="frame" id="thea" style="width: 100%">
                    <div style="text-align: center; font-weight: bold">
                        @{
                          if (fDate > tDate)
                          {
                              message = "Ngày trong mục 'Từ ngày' không được lớn hơn ngày trong mục 'Đến ngày'";
                          }
                          else
                          {
                              message = "Không có dữ liệu giao dịch của các rạp trong thời gian từ " + fDate.ToString("dd/MM/yyyy") + " đến " + tDate.ToString("dd/MM/yyyy");
                          }
                        }
                        @message
                    </div>
                </div>
            </div>
        </div>
    }
</div>
<div>
    @*<a href="~/Report/AdminReport">Quay lại</a>*@
    <div>
        <button class="button danger" style="float: right">
            @Html.ActionLink("Quay Lại", "/AdminReport")
        </button>
    </div>
</div>
<script>
    $("#btnPrintTab1").click(function () {
        //var prtContent1 = document.getElementById("system").innerHTML;
        //var prtContent2 = document.getElementById("suppliers").innerHTML;
        //var prtContent3 = document.getElementById("theaters").innerHTML;
        //var divElement = '<h2>Thống kê tổng quan hệ thống</h2>' + prtContent1 + '<br \>'
        //    + '<h2>Thống kê các đối tác</legend>' + prtContent2 + '<br \>'
        //    + '<h2>Thống kê các rạp</legend>' + prtContent3 + '<br \>';

        var titleText = '<h1>' + document.getElementById("ReportTitle").innerHTML + '</h1><hr \>';
        var tabText = '<h2>' + document.getElementById("titletab1").innerHTML + '</h2><br \>';
        var prtContent = document.getElementById("system").innerHTML;

        var WinPrint = window.open('', '', 'letf=0,top=0,width=800,height=700');
        WinPrint.document.write('<html><head>');
        WinPrint.document.write('<link href="~/css/metro-bootstrap.css" rel="stylesheet" /><link href="~/css/own.css" rel="stylesheet" />');
        WinPrint.document.write('</head><body><div class="metro">');
        WinPrint.document.write('<style>.center {text-align: center;}.right {text-align: right;} .detail{display:none} .unoverflow{overflow-y:visible}');
        WinPrint.document.write('table,th,td{border:1px solid; border-color:gray;border-collapse:collapse; padding-bottom:10px;}</style>');
        WinPrint.document.write('<body><div>');
        WinPrint.document.write(titleText);
        WinPrint.document.write(tabText);
        WinPrint.document.write(prtContent);
        WinPrint.document.write('</div></body></html>');
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        //WinPrint.close() 
    })
    $("#btnPrintTab2").click(function () {
        var titleText = '<h1>' + document.getElementById("ReportTitle").innerHTML + '</h1><hr \>';
        var tabText = '<h2>' + document.getElementById("titletab2").innerHTML + '</h2><br \>';
        var prtContent = document.getElementById("suppliers").innerHTML;

        var WinPrint = window.open('', '', 'letf=0,top=0,width=800,height=700');
        WinPrint.document.write('<html><head>');
        WinPrint.document.write('<link href="~/css/metro-bootstrap.css" rel="stylesheet" /><link href="~/css/own.css" rel="stylesheet" />');
        WinPrint.document.write('</head><body><div class="metro">');
        WinPrint.document.write('<style>.center {text-align: center;}.right {text-align: right;} .detail{display:none} .unoverflow{overflow-y:visible}');
        WinPrint.document.write('table,th,td{border:1px solid; border-color:gray;border-collapse:collapse; padding-bottom:10px;}</style>');
        WinPrint.document.write('<body><div>');
        WinPrint.document.write(titleText);
        WinPrint.document.write(tabText);
        WinPrint.document.write(prtContent);
        WinPrint.document.write('</div></body></html>');
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        //WinPrint.close() 
    })
    $("#btnPrintTab3").click(function () {
        var titleText = '<h1>' + document.getElementById("ReportTitle").innerHTML + '</h1><hr \>';
        var tabText = '<h2>' + document.getElementById("titletab3").innerHTML + '</h2><br \>';
        var prtContent = document.getElementById("theaters").innerHTML;

        var WinPrint = window.open('', '', 'letf=0,top=0,width=800,height=700');
        WinPrint.document.write('<html><head>');
        WinPrint.document.write('<link href="~/css/metro-bootstrap.css" rel="stylesheet" /><link href="~/css/own.css" rel="stylesheet" />');
        WinPrint.document.write('</head><body><div class="metro">');
        WinPrint.document.write('<style>.center {text-align: center;}.right {text-align: right;} .detail{display:none} .unoverflow{overflow-y:visible}');
        WinPrint.document.write('table,th,td{border:1px solid; border-color:gray;border-collapse:collapse; padding-bottom:10px;}</style>');
        WinPrint.document.write('<body><div>');
        WinPrint.document.write(titleText);
        WinPrint.document.write(tabText);
        WinPrint.document.write(prtContent);
        WinPrint.document.write('</div></body></html>');
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        //WinPrint.close() 
    })
    $("#btnPrintTab4").click(function () {
        var titleText = '<h1>' + document.getElementById("ReportTitle").innerHTML + '</h1><hr \>';
        var tabText = '<h2>' + document.getElementById("titletab4").innerHTML + '</h2><br \>';
        var prtContent = document.getElementById("overview").innerHTML;

        var WinPrint = window.open('', '', 'letf=0,top=0,width=800,height=700');
        WinPrint.document.write('<html><head>');
        WinPrint.document.write('<link href="~/css/metro-bootstrap.css" rel="stylesheet" /><link href="~/css/own.css" rel="stylesheet" />');
        WinPrint.document.write('</head><body><div class="metro">');
        WinPrint.document.write('<style>.center {text-align: center;}.right {text-align: right;} .detail{display:none} .unoverflow{overflow-y:visible}');
        WinPrint.document.write('table,th,td{border:1px solid; border-color:gray;border-collapse:collapse; padding-bottom:10px;}</style>');
        WinPrint.document.write('<body><div>');
        WinPrint.document.write(titleText);
        WinPrint.document.write(tabText);
        WinPrint.document.write(prtContent);
        WinPrint.document.write('</div></body></html>');
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        //WinPrint.close() 
    })
    $("#btnPrintTab5").click(function () {
        var titleText = '<h1>' + document.getElementById("ReportTitle").innerHTML + '</h1><hr \>';
        var tabText = '<h2>' + document.getElementById("titletab5").innerHTML + '</h2><br \>';
        var prtContent = document.getElementById("suppliertheaters").innerHTML;

        var WinPrint = window.open('', '', 'letf=0,top=0,width=800,height=700');
        WinPrint.document.write('<html><head>');
        WinPrint.document.write('<link href="~/css/metro-bootstrap.css" rel="stylesheet" /><link href="~/css/own.css" rel="stylesheet" />');
        WinPrint.document.write('</head><body><div class="metro">');
        WinPrint.document.write('<style>.center {text-align: center;}.right {text-align: right;} .detail{display:none} .unoverflow{overflow-y:visible}');
        WinPrint.document.write('table,th,td{border:1px solid; border-color:gray;border-collapse:collapse; padding-bottom:10px;}</style>');
        WinPrint.document.write('<body><div>');
        WinPrint.document.write(titleText);
        WinPrint.document.write(tabText);
        WinPrint.document.write(prtContent);
        WinPrint.document.write('</div></body></html>');
        WinPrint.document.close();
        WinPrint.focus();
        WinPrint.print();
        //WinPrint.close() 
    })
</script>
